package com.cxj.magic;

import android.content.Context;
import android.view.MotionEvent;
import android.view.ScaleGestureDetector;

public abstract class VersionedGestureDetector {
    OnGestureListener mListener;

    public static VersionedGestureDetector newInstance(Context paramContext, OnGestureListener paramOnGestureListener) {
        VersionedGestureDetector localObject = new FroyoDetector(paramContext);
        localObject.mListener = paramOnGestureListener;
        return localObject;
    }

    public abstract boolean onTouchEvent(MotionEvent paramMotionEvent);

    private static class CupcakeDetector extends VersionedGestureDetector {
        float mLastTouchX;
        float mLastTouchY;

        float getActiveX(MotionEvent paramMotionEvent) {
            return paramMotionEvent.getX();
        }

        float getActiveY(MotionEvent paramMotionEvent) {
            return paramMotionEvent.getY();
        }

        public boolean onTouchEvent(MotionEvent paramMotionEvent) {
            int action = paramMotionEvent.getAction();
            if (action == 0) {
                this.mLastTouchX = getActiveX(paramMotionEvent);
                this.mLastTouchY = getActiveY(paramMotionEvent);
                return true;
            }

            if (action == 1) {
                return true;
            }
            if (action == 2) {
                float f1 = getActiveX(paramMotionEvent);
                float f2 = getActiveY(paramMotionEvent);
                if (shouldDrag())
                    this.mListener.onDrag(f1 - this.mLastTouchX, f2 - this.mLastTouchY);
                this.mLastTouchX = f1;
                this.mLastTouchY = f2;
                return true;

            }
            return true;
        }

        boolean shouldDrag() {
            return true;
        }
    }

    private static class EclairDetector extends VersionedGestureDetector.CupcakeDetector {
        private static final int INVALID_POINTER_ID = -1;
        private int mActivePointerId = -1;
        private int mActivePointerIndex = 0;

        private EclairDetector() {
            super();
        }

        float getActiveX(MotionEvent paramMotionEvent) {
            return paramMotionEvent.getX(this.mActivePointerIndex);
        }

        float getActiveY(MotionEvent paramMotionEvent) {
            return paramMotionEvent.getY(this.mActivePointerIndex);
        }

        public boolean onTouchEvent(MotionEvent paramMotionEvent) {
            switch (0xFF & paramMotionEvent.getAction()) {
            case 2:
            case 4:
            case 5:
                this.mActivePointerIndex = paramMotionEvent.findPointerIndex(this.mActivePointerId);
                return super.onTouchEvent(paramMotionEvent);
            case 0:
                this.mActivePointerId = paramMotionEvent.getPointerId(0);
                this.mActivePointerIndex = paramMotionEvent.findPointerIndex(this.mActivePointerId);
                return super.onTouchEvent(paramMotionEvent);
            case 1:
            case 3:
                this.mActivePointerId = -1;
                this.mActivePointerIndex = paramMotionEvent.findPointerIndex(this.mActivePointerId);
                return super.onTouchEvent(paramMotionEvent);
            case 6:
                int i = (0xFF00 & paramMotionEvent.getAction()) >> 8;
                if (paramMotionEvent.getPointerId(i) != this.mActivePointerId) {
                    this.mActivePointerIndex = paramMotionEvent.findPointerIndex(this.mActivePointerId);
                    return super.onTouchEvent(paramMotionEvent);
                } else {
                    int j = (i == 0 ? 1 : 0);
                    this.mActivePointerId = paramMotionEvent.getPointerId(j);
                    this.mLastTouchX = paramMotionEvent.getX(j);
                    this.mLastTouchY = paramMotionEvent.getY(j);
                    this.mActivePointerIndex = paramMotionEvent.findPointerIndex(this.mActivePointerId);
                    return super.onTouchEvent(paramMotionEvent);
                }
            default:
                this.mActivePointerIndex = paramMotionEvent.findPointerIndex(this.mActivePointerId);
                return super.onTouchEvent(paramMotionEvent);
            }
        }
    }

    private static class FroyoDetector extends VersionedGestureDetector.EclairDetector {
        private ScaleGestureDetector mDetector;

        public FroyoDetector(Context paramContext) {
            super();
            this.mDetector = new ScaleGestureDetector(paramContext, new ScaleGestureDetector.SimpleOnScaleGestureListener() {
                public boolean onScale(ScaleGestureDetector paramScaleGestureDetector) {
                    VersionedGestureDetector.FroyoDetector.this.mListener.onScale(paramScaleGestureDetector.getScaleFactor());
                    return true;
                }
            });
        }

        public boolean onTouchEvent(MotionEvent paramMotionEvent) {
            this.mDetector.onTouchEvent(paramMotionEvent);
            return super.onTouchEvent(paramMotionEvent);
        }

        boolean shouldDrag() {
            return !this.mDetector.isInProgress();
        }
    }

    public static abstract interface OnGestureListener {
        public abstract void onDrag(float paramFloat1, float paramFloat2);

        public abstract void onScale(float paramFloat);
    }
}

/* Location:           F:\temp\tools\classes_dex2jar.jar
 * Qualified Name:     maxstrom.app.theme.nanrenzhi1.VersionedGestureDetector
 * JD-Core Version:    0.6.0
 */